﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace THO7AlgoritmTimerApplication
{
    public class SortArray
    {
        public byte Replace(byte[] add, byte[] remove)
        {

            byte middle = 125;
            int addLength = add.Length;
            int rmLength = add.Length;

            byte[] addLower = new byte[addLength];
            byte[] addHigher = new byte[addLength];

            byte[] rmLower = new byte[rmLength];
            byte[] rmHigher = new byte[rmLength];

            int addLowerCnt = 0;
            int addHigherCnt = 0;

            int rmLowerCnt = 0;
            int rmHightCnt = 0;

            for (int x = 0; x < addLength; x++)
            {
                if(add[x] < middle)
                {
                    addLower[addLowerCnt++] = add[x];   
                }
                else if(add[x] > middle)
                {
                    addHigher[addHigherCnt++] = add[x];
                }

                if (remove[x] < middle)
                {
                    rmLower[rmLowerCnt++] = remove[x];
                }
                else if (remove[x] > middle)
                {
                    rmHigher[rmHightCnt++] = remove[x];
                }
            }

            return add[(addLength / 2)];
        }
    }
}
